home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 4 / The 640 Meg Shareware Studio CD-ROM Volume IV (Data Express)(1994).ISO / clang / 120_01.zip / META43.C < prev    next >
Text File  |  1993-06-01  |  2KB  |  92 lines

  1.  
  2.  
  3. #include "meta40.h"
  4.  
  5.  
  6.  
  7. /*
  8.     Here we define file i/o and the pack/unpack functions
  9.     CR's are filtered and the ER variable is set/reset in
  10.     the file i/o functions.
  11.  
  12.                                     J.L. oct. -81
  13. */
  14.  
  15.  
  16. pack( a, b, c )
  17. unsigned *a ;
  18. char *b, *c ;
  19. {
  20.     *a = (*b << 8) | *c ;
  21. }
  22.  
  23. unpack( a, b, c )
  24. unsigned *a ;
  25. char *b, *c ;
  26. {
  27.     *c = *a & 0x00ff ;
  28.     *b = *a >> 8 ;
  29. }
  30.  
  31. xopen( name, buf )
  32. char *name, *buf ;
  33. {
  34.     if(fopen( name, buf ) == ERROR)er = 1 ; else er = 0 ;
  35.     eoflag = FALSE ;
  36. }
  37.  
  38. xclose( buf )
  39. char *buf ;
  40. {
  41.     fclose( buf );
  42.     er = 0 ;
  43. }
  44.  
  45. gchar( buf )
  46. char *buf ;
  47. {
  48.     char c ;
  49.  
  50.     c = 0x0d ; er = 0;
  51.     while(c == 0x0d && er == 0){
  52.         if((c = getc(buf)) == ERROR || c == CPMEOF)er = 1 ; else er = 0 ;
  53.         if(er)eoflag = TRUE ;
  54.         if(printflag && c != CPMEOF && !eoflag)putchar(c);
  55.         }
  56.     return(tolower(c));
  57. }
  58.  
  59.  
  60. pchar( c, buf )
  61. char c, *buf ;
  62. {  
  63.     if(spcharflag){
  64.            spcharflag = FALSE ;
  65.         if(c == 't')c = 9; else if(c == 'n')c = '\n' ;
  66.         }
  67.     else if(c == '\\'){spcharflag = TRUE; er = 0 ; return ;}
  68.     if(c == '\n')if(putc(0x0d,buf) == ERROR)er = 1 ; else er = 0 ;
  69.     if(putc(c,buf) == ERROR)er = 1 ; else er = 0 ;
  70. }
  71.  
  72.  
  73. xcreat( name, buf )    
  74. char *name, *buf ;
  75. {
  76.     if(fcreat( name, buf ) == ERROR)er = 1 ; else er = 0 ;
  77. }
  78.  
  79.  
  80. newext( s, n )
  81. char *s, *n ;
  82. {
  83.     char *i ;
  84.  
  85.     i = s ;
  86.     while(*s != NULL && *s != '.')s++;
  87.     if(*s == '.')*s = NULL ;
  88.     strcat( i, n );
  89. }
  90.  
  91.     
  92.